<?php if (!$this->member):?>
<div class="alert alert-block alert-error">
    <a class="close" data-dismiss="alert" >&times;</a>
    <h4>尊敬的淘车乐用户您好, 感谢您选择淘车乐优质服务！ </h4>
    <p>未登陆用户每天只能发布一条信息并且不能管理已发布车源, <a href="javascript:;" data="<?= $this->url(array('controller'=>'dialog','action'=>'login','ref'=>$this->ref,'isre'=>1),null,true)?>" id="showWindow">立即登陆</a>会员账号尊享免费无限发布特权! 还没有账号? <a href="<?= $this->url(array('controller'=>'member','action'=>'register','ref'=>$this->ref),null,true)?>">免费注册</a></p>
</div>
<?php endif;?>

<hr />
<h3><?php if ($this->op == 'edit'):?>修改<?php else:?>填写<?php endif;?>您的爱车信息</h3>
<?php if ($this->geterror):?>
<div class="alert alert-block alert-error">
    <button type="button" class="close" data-dismiss="alert">&times;</button>
    <h4>出错啦, 请检查以下错误项！</h4>
    <?= $this->geterror?>
</div>
<?php endif;?>



<div class="span12 set_sale">

<form name="form" action="" method="post">

    <dl class="dl-horizontal">
    
        <dt><em>*</em> 车型</dt>
        <dd>
            <select name="brand" id="s_brand" data-toggle="popover">
                <option value="0">-请选择车辆品牌-</option>  
	            <?php foreach ($this->allbrand as $allbrand):?>
					<optgroup label="-- <?= strtoupper($allbrand[s_py])?> --"></optgroup>
						<?php foreach ($allbrand[arr] as $brand):?>
							<option <?php if($i%2 == 0): ?>style="background: #DBDBDB;"<?php endif;?> <?php if ($this->getdata[brand] == $brand[id]):?>selected<?php endif;?> value="<?= $brand[id]?>"><?= strtoupper($allbrand[s_py])."&nbsp;&nbsp;".$brand[brand]?></option>  						<?php endforeach;?>	
						<?php $i++;?>
				<?php endforeach;?>	
            </select>
            <select name="model" id="s_model" <?php if (!$this->getdata[brand]):?>style="display:none"<?php endif;?>>
                <?php if ($this->getdata[model] == 0):?><option value="0">-请选择车系-</option><?php endif;?>
                <?php foreach ($this->modeldata as $company):?>
                    <optgroup label="-- <?=$company[company]?> --"></optgroup>
                    <?php foreach ($company[model] as $model):?>
                        <option <?php if ($this->getdata[model] == $model[id]):?>selected<?php endif;?> value="<?= $model[id]?>" ><?= $model[model]?></option>
                    <?php endforeach;?>
                <?php endforeach;?>
            </select>
            <select name="carname" id="s_carname" <?php if (!$this->getdata[carname] || $this->getdata[is_write] == 1):?>style="display:none"<?php endif;?>>
                <?php if ($this->getdata[carname] == 0):?><option value="0">-请选择车型-</option><?php endif;?>
                <?php foreach ($this->carnamedata as $carname):?>
                	<option <?php if ($this->getdata[carname] == $carname[id]):?>selected<?php endif;?> value="<?= $carname[id]?>" ><?= $carname[name]?></option>
                <?php endforeach;?>

            </select>
            <input type="text" <?php if ($this->getdata[is_write] == 0):?>style="display:none"<?php endif;?> value="<?php if ($this->getdata[model_text]):?><?= $this->getdata[model_text] ?><?php else: ?>请在此输入车型名称<?php endif;?>" id="model_text" name="model_text" autocomplete="off" />
            <input type="hidden" value="<?= $this->getdata[is_write] ?>" name="is_write" id="is_write" />
            <span class="help-inline" id="s_write" style="display:none">没有找到您的车型? <a href="javascript:;" id="write_model">切换为手动输入车型</a></span>
            <span class="help-inline" id="c_brand"></span>
        </dd>
        
        <dt><em>*</em> 车辆颜色</dt>
        <dd>
            <select name="color" id="s_color">
                <option value="0">-请选择车辆颜色-</option>  
                <?php foreach ($this->allcolor as $allcolor): ?>
                    <option <?php if ($this->getdata[color] == $allcolor[id]):?>selected<?php endif;?> value="<?= $allcolor[id]?>" style="background-color:<?= $allcolor[color_value]?>;<?php if ($allcolor[color_value] == '#000000'):?>color:#FFFFFF<?php else: ?>color:#000000<?php endif;?>"><?= $allcolor[color_name]?></option>  
                <?php endforeach;?>
            </select>
            <i style="display:none;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</i>
            <span class="help-inline" id="c_color"></span>
            
        </dd>
        
        <dt><em>*</em> 车辆所在地</dt>
        <dd>
            <select name="province" id="s_province">
                <option value="0">-请选择省份-</option>  
                <?php foreach ($this->allcity as $allcity): ?>
                    <option <?php if ($this->getdata[province] == $allcity[id]):?>selected<?php endif;?> value="<?= $allcity[id]?>"><?= $allcity[name]?></option>  
                <?php endforeach;?>
            </select>
            <select name="city" id="s_city" <?php if (!$this->getdata[province]):?>style="display:none"<?php endif;?>>
                <?php if ($this->getdata[city] == 0):?><option value="0">-请选择城市-</option><?php endif;?>
                <?php foreach ($this->citydata as $city):?>
                    <option <?php if ($this->getdata[city] == $city[id]):?>selected<?php endif;?> value="<?= $city[id]?>" ><?= $city[name]?></option>
                <?php endforeach;?>
            </select>
            <span class="help-inline" id="c_province"></span>
        </dd>

        <dt><em>*</em> 行驶里程</dt>
        <dd>
            <div class="input-append">
                <input type="text" placeholder="车辆行驶里程" maxlength="10" name="kilometer" value="<?= $this->getdata[kilometer]?>" autocomplete="off" /><span class="add-on">公里</span>
            </div>
            <span class="help-inline" id="c_kilometer"></span>
        </dd>
        
        <dt><em>*</em> 首次上牌日期</dt>
        <dd>
            <select name="car_year" id="">
                <option value="0">-请选择年份-</option>  
                <?php foreach ($this->config[start_arr] as $start_arr): ?>
                    <option <?php if ($this->getdata[car_year] == $start_arr):?>selected<?php endif;?> value="<?= $start_arr?>"><?= $start_arr?>年</option>  
                <?php endforeach;?>
            </select>
            <select name="car_month" id="">
                <option value="0">-请选择月份-</option>  
                <?php foreach ($this->config[month_arr] as $month_arr): ?>
                    <option <?php if ($this->getdata[car_month] == $month_arr):?>selected<?php endif;?> value="<?= $month_arr?>"><?= $month_arr?>月</option>  
                <?php endforeach;?>
            </select>
            <span class="help-inline" id="car_year"></span>
        </dd>
        
        <dt><em>*</em> 年检有效期至</dt>
        <dd>
            <select name="check_year" id="">
                <option value="0">-请选择年份-</option>  
                <option <?php if ($this->getdata[check_year] == -1):?>selected<?php endif;?> value="-1">已过期</option>  
                <?php foreach ($this->config[year_arr] as $year_arr): ?>
                    <option <?php if ($this->getdata[check_year] == $year_arr):?>selected<?php endif;?> value="<?= $year_arr?>"><?= $year_arr?>年</option>  
                <?php endforeach;?>
            </select>
            <select name="check_month" id="" <?php if (!$this->getdata[check_month] || $this->getdata[check_year] == -1): ?>style="display: none;"<?php endif;?>>
                <option value="0">-请选择月份-</option>  
                <?php foreach ($this->config[month_arr] as $month_arr): ?>
                    <option <?php if ($this->getdata[check_month] == $month_arr):?>selected<?php endif;?> value="<?= $month_arr?>"><?= $month_arr?>月</option>  
                <?php endforeach;?>
            </select>
            <span class="help-inline" id="check_year"></span>
        </dd>
        
        <dt><em>*</em> 保险有效期至</dt>
        <dd>
            <select name="safe_year" id="">
                <option value="0">-请选择年份-</option>  
                <option <?php if ($this->getdata[safe_year] == -1):?>selected<?php endif;?> value="-1">已过期</option>  
                <?php foreach ($this->config[year_arr] as $year_arr): ?>
                    <option <?php if ($this->getdata[safe_year] == $year_arr):?>selected<?php endif;?> value="<?= $year_arr?>"><?= $year_arr?>年</option>  
                <?php endforeach;?>
            </select>
            <select name="safe_month" id="" <?php if (!$this->getdata[safe_month] || $this->getdata[safe_year] == -1): ?>style="display: none;"<?php endif;?>>
                <option value="0">-请选择月份-</option>  
                <?php foreach ($this->config[month_arr] as $month_arr): ?>
                    <option <?php if ($this->getdata[safe_month] == $month_arr):?>selected<?php endif;?> value="<?= $month_arr?>"><?= $month_arr?>月</option>  
                <?php endforeach;?>
            </select>
            <span class="help-inline" id="safe_year"></span>
        </dd>
        
        

        <dt> 车源图片</dt>
        <dd>
            <span id="spanButtonPlaceHolder"></span>
           	<div class="fieldset flash" id="fsUploadProgress">
           	<?php if ($this->getdata[img_arr]):?>
           		<?php foreach ($this->getdata[img_arr] as $k=>$value):?>
           		<div class="progressWrapper" id="SWFUpload_0_<?= 20-$k?>"><div class="progressContainer blue"><a class="progressCancel" style="visibility: visible; display: none;"> </a><div class="progressName <?php if ($value == $this->getdata[front]):?>Front_vis<?php endif;?>" id="PicSWFUpload_0_<?= 20-$k?>"><img src="<?= $this->getdata[img_dir].$this->session_id.'/'.$this->session_id.str_replace('.', '_small.', $value)?>"><input type="hidden" value="<?= $value?>" name="pic_arr[]"></div><div class="progressBarStatus"><div style="text-align:center"><b>上传完成</b> <a href="javascript:add_front('SWFUpload_0_<?= 20-$k?>');">设为封面</a> | <a href="javascript:del_upload('SWFUpload_0_<?= 20-$k?>');">删除</a></div></div><div class="progressBarComplete" style=""></div></div></div>
           		<?php endforeach;?>
           	<?php endif;?>
           	</div>
    		<div id="divStatus"></div>	
    		
    		<input id="btnCancel" type="button" value="取消上传" onclick="swfu.cancelQueue();" disabled="disabled" style="display:none;" />
            <span class="help-inline"><div id="divStatusAll">按住CTRL键可多选图片, 最多上传20张图片, 第一张默认为封面</div></span>
            <p><img src="/img/upload_example.png" alt="" /></p>
        </dd>
            <style type="text/css">
                .flash{
                	width: 100%;
                	float:left;
                }
                .progressWrapper {
                    float: left;
                    overflow: hidden;
                    width: 130px;
                }
                
                .progressContainer {
                	margin: 5px;
                	padding: 4px;
                	border: solid 1px #E8E8E8;
                	background-color: #F7F7F7;
                	overflow: hidden;
                }
                /* Message */
                .message {
                	margin: 1em 0;
                	padding: 10px 20px;
                	border: solid 1px #FFDD99;
                	background-color: #FFFFCC;
                	overflow: hidden;
                }
                /* Error */
                .red {
                	border: solid 1px #B50000;
                	background-color: #FFEBEB;
                }
                
                /* Current */
                .green {
                	border: solid 1px #DDF0DD;
                	background-color: #EBFFEB;
                }
                
                /* Complete */
                .blue {
                	border: solid 1px #CEE2F2;
                	background-color: #F0F5FF;
                }
                
                .progressName {
                	font-size: 14px;
                	font-weight: 700;
                	color: #555;
                	width: 100%;
                	text-align: left;
                	white-space: nowrap;
                	overflow: hidden;
                }
                
                .progressBarInProgress,
                .progressBarComplete,
                .progressBarError {
                	font-size: 0;
                	width: 0%;
                	height: 2px;
                	background-color: blue;
                	margin-top: 2px;
                }
                
                .progressBarComplete {
                	width: 100%;
                	background-color: green;
                	visibility: hidden;
                }
                
                .progressBarError {
                	width: 100%;
                	background-color: red;
                	visibility: hidden;
                }
                
                .progressBarStatus {
                	margin-top: 2px;
                	width: 100%;
                	font-size: 7pt;
                	font-family: Arial;
                	text-align: left;
                	white-space: nowrap;
                }

                
                a.progressCancel {
                	font-size: 0;
                	display: block;
                	height: 14px;
                	width: 14px;
                	background-image: url(/swfupload/images/cancelbutton.gif);
                	background-repeat: no-repeat;
                	background-position: -14px 0px;
                	float: right;
                }
                
                a.progressCancel:hover {
                	background-position: 0px 0px;
                }
            </style>
            <script type="text/javascript" src="/swfupload/swfupload/swfupload.js"></script>
            <script type="text/javascript" src="/swfupload/js/swfupload.queue.js"></script>
            <script type="text/javascript" src="/swfupload/js/fileprogress.js"></script>
            <script type="text/javascript" src="/swfupload/js/handlers.js"></script>

            <script type="text/javascript">
            		var swfu;
            
            		window.onload = function() {
            			var settings = {
            				flash_url : "/swfupload/swfupload/swfupload.swf",
            				upload_url: "/ajax/upload",	
            				post_params: {"session_id" : "<?= $this->session_id; ?>"},
            				file_size_limit : "20 MB",
            				file_types : "*.jpg; *.jpeg; *.png;",
            				file_types_description : "图片",
            				file_upload_limit : 20,  //配置上传个数
            				file_queue_limit : 20,
            				custom_settings : {
            					progressTarget : "fsUploadProgress",
            					cancelButtonId : "btnCancel"
            				},
            				
            				debug: false,
            
            				// Button settings
            				button_image_url: "/img/swfupload_btn.png",
            				button_width: "129",
            				button_height: "33",
            				button_placeholder_id: "spanButtonPlaceHolder",
            				
            				button_text: '<span class="theFont"><b>上传车源图片</b></span>',
            				button_text_style: ".theFont { font-size: 16;color:#FFFFFF; }",
            				button_text_left_padding: 12,
            				button_text_top_padding: 6,
            				
            				file_queued_handler : fileQueued,
            				file_queue_error_handler : fileQueueError,
            				file_dialog_complete_handler : fileDialogComplete,
            				upload_start_handler : uploadStart,
            				upload_progress_handler : uploadProgress,
            				upload_error_handler : uploadError,
            				upload_success_handler : uploadSuccess,
            				upload_complete_handler : uploadComplete,
            				queue_complete_handler : queueComplete	
            			};

            			swfu = new SWFUpload(settings);
        	              <?php if ($this->getdata[img_arr]):?>
        	                num = parseInt(<?= count($this->getdata[img_arr])?>);
        	           	 	setTimeout(function () {
        	                  	nowUploadNum(num);
        	            		$.post("/ajax/updatepicnum",{session_id:<?= $this->session_id; ?>, num:num},function(result){   
        	            			return true;
        	            		});
        	           	 	}, 1000);
              	          <?php endif;?>
            	     };
            </script>

           
            <input type="hidden" name="session_id" value="<?= $this->session_id; ?>" id="session_id" />
            <input type="hidden" name="front" value="<?= $this->getdata[front]?>" id="front" />
        <br />
        
        <dt><em>*</em> 车辆用途性质</dt>
        <dd>
            <label class="radio inline">
                <input type="radio"  value="0" id="car_operate" name="car_operate" <?php if ($this->getdata[car_operate] == 0):?>checked<?php endif;?>> 非营运
            </label>
            <label class="radio inline">
                <input type="radio"  value="1" id="car_operate" name="car_operate" <?php if ($this->getdata[car_operate] == 1):?>checked<?php endif;?>> 营运
            </label>
            <label class="radio inline">
                <input type="radio"  value="2" id="car_operate" name="car_operate" <?php if ($this->getdata[car_operate] == 2):?>checked<?php endif;?>> 营专非
            </label>
            <span class="help-inline check_right">&nbsp;</span>
        </dd>
        
        <dt><em>*</em> 定期保养</dt>
        <dd>
            <label class="radio inline">
                <input type="radio"  value="0" id="maintenance" name="maintenance" <?php if ($this->getdata[maintenance] == 0):?>checked<?php endif;?>> 4S店定期保养
            </label>
            <label class="radio inline">
                <input type="radio"  value="1" id="maintenance" name="maintenance" <?php if ($this->getdata[maintenance] == 1):?>checked<?php endif;?>> 非4S店定期保养
            </label>
            <label class="radio inline">
                <input type="radio" value="2" id="maintenance" name="maintenance" <?php if ($this->getdata[maintenance] == 2):?>checked<?php endif;?>> 无定期保养
            </label>
            <span class="help-inline check_right">&nbsp;</span>
        </dd>
        
        <dt><em>*</em> 车主自述</dt>
        <dd>
            <textarea id="textarea" class="input-xlarge" cols="20" rows="2" name="note" maxlength="480" placeholder="例：我一直很爱惜自己的车，每次保养都是在4S店保养，小刮擦在所难免但绝对没有大事故。加装了自动大灯，门灯，点火线圈，胎压监测。保险还有9个月到期，可随时看车！"><?= $this->getdata[note]?></textarea>
            <span class="help-inline" id="c_note"></span>
        </dd>
        
        <dt><em>*</em> 预售价格</dt>
        <dd>
            <div class="input-append">
                <input type="text" name="price" value="<?= $this->getdata[price]?>" maxlength="6" placeholder="您希望卖多少钱? 万元" autocomplete="off" /><span class="add-on">万元</span>
            </div>
            <span class="help-inline" id="c_price"></span> 
        </dd>
        
        <dt><em>*</em> 联系人</dt>
        <dd>
            <input type="text" name="contact_user" maxlength="20" value="<?php if($this->getdata[contact_user]):?><?= $this->getdata[contact_user]?><?php else:?><?= $this->getdata[u_contact_user]?><?php endif;?>" placeholder="您的真实姓名" autocomplete="off" />
            <span class="help-inline" id="c_contact_user"></span>
        </dd>

        <dt><em>*</em> 联系手机</dt>
        <dd>
            <input type="text" name="contact_tel" maxlength="11" value="<?php if($this->getdata[contact_tel]):?><?= $this->getdata[contact_tel]?><?php else:?><?= $this->getdata[u_contact_tel]?><?php endif;?>" placeholder="您的联系手机" autocomplete="off" />
            <span class="help-inline" id="contact_tel"></span>
        </dd>
        
        <hr />
        
        <!--dt> 我要推广</dt>
        <dd>
            <label class="checkbox">
                <input type="checkbox" name="profit[]" value="0" />置顶/高级置顶（将本帖置顶到列表页顶部，快速获得推广效果24.88元/天起）
            </label>
            <label class="checkbox">
                <input type="checkbox" name="profit[]" value="1" />定向推广,右侧广告（0.22元/点击）
            </label>
            <p><a href="">什么是推广信息? 效果如何? 点击了解详情。</a></p>
        </dd>
        
        <br /-->
        
        <dt></dt>
        <dd><button class="btn btn-danger btn-large" type="submit" id="sale_sub" ><?php if ($this->op == 'edit'):?>更新信息<?php else:?>立即发布<?php endif;?></button></dd>
        <!-- dt></dt>
        <dd><a href="<?= $this->url(array('controller'=>'buy','action'=>'index'))?>" onclick="" id="stop_sale"><i class="icon-chevron-left"></i> 我暂时不想发布, 返回继续浏览</a></dd-->
    </dl>
    
    <input type="hidden" value="<?= $this->op?>" name="submod" />
    <input type="hidden" value="<?= $this->cid?>" name="cid" />
</form>
</div>